

// 接口 interface 
// 对ajax 进行二次封装 (发送ajax 请求 返回Promise 实例)

function request(url,data="",type="get"){
    return new Promise(function(resolve,reject){
        $.ajax({
            type,
            url,
            data,
            dataType:"json",
            success:res=>{
                // ajax 请求成功 => promise 状态就改变了  => 把数据存储到 Promise 实例  => then 获取
                resolve(res)
            }
        })
    })
}

// params 当做一个对象作为参数 
const isExistUser = params=> request("../php/isExistUser.php",params,'get');
const isExistPhone = params=> request("../php/isExistPhone.php",params,'get');
const isExistEmail = params=> request("../php/isExistEmail.php",params,'get');


const login = params=> request("../php/login.php",params,'post');

// 成绩列表 
const getAllGrade = params=> request("../php/01_getAllGrade.php",params);

const getCartList = params =>request("../good/08_getCartList.php",params,'post');

const deleteCartOne = params =>request("../good/09_deleteCartById.php",params,'get');

// async + await 

